﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sitecore.Data.Items;

namespace Workflow.Alerts.Sublayouts
{
    public partial class PartiallyApprove : BaseControl, IPartApproveView
    {
        #region Events
        protected void Page_Load(object sender, EventArgs e)
        {
            PresentationManager.RegisterView(typeof(PartApproveViewPresenter), this, new WebSessionProvider());
            if (!IsPostBack && PartApproveLoad != null)
                PartApproveLoad();
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (PartApproveSave != null)
                PartApproveSave();
            phClose.Visible = true;
        }
        #endregion

        #region IPartApproveView Members

        public string Comments
        {
            get
            {
                return txtComments.Text;
            }
            set
            {
                txtComments.Text = value;
            }
        }

        public int AlertId
        {
            get { return Int32.Parse(Request.QueryString["alertId"]); }
        }

        public DateTime? StartDate
        {
            get
            {
                return rdpStartDate.SelectedDate;
            }
            set
            {
                rdpStartDate.SelectedDate = value;
            }
        }

        public DateTime? EndDate
        {
            get
            {
                return rdpEndDate.SelectedDate;
            }
            set
            {
                rdpEndDate.SelectedDate = value;
            }
        }

        public bool TrafficProblems
        {
            //get
            //{
            //    return rbTrafficJa.Checked;
            //}
            //set
            //{

            //    rbTrafficJa.Checked = value;
            //    rbTrafficNee.Checked = !value;
            //}
            get { return Boolean.Parse(rblTrafficProblems.SelectedItem.Value); }
            set
            {
                rblTrafficProblems.ClearSelection();
                rblTrafficProblems.Items.FindByValue(value.ToString()).Selected = true;
            }

        }

        public event OnPartApproveLoad PartApproveLoad;

        public event OnPartApproveSave PartApproveSave;

        #endregion
    }
}